<template>
    <!-- 供应商变更查看页面 -->
    <div class="e-form">
        <div class="tabs" v-if="Object.keys(basicFormData).length != 0">
            <el-tabs
                tab-position="left"
                v-model="tabsName"
                @tab-click="onChangeTab"
            >
                <!-- 基本信息 -->
                <el-tab-pane
                    label="基本信息"
                    name="baseInfo"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <el-tab-pane
                    label="资质信息"
                    name="aptitude"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <el-tab-pane
                    label="历史业绩"
                    name="firmPerformance"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <el-tab-pane
                    label="解除处罚记录"
                    name="alteration"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <el-tab-pane
                    label="审核历史"
                    name="accessory"
                    :disabled="clickTabFlag"
                ></el-tab-pane>
                <div>
                    <!-- 基本信息 -->
                    <div id="baseInfoCon" class="con">
                        <div class="e-form">
                            <div class="tabs">
                                <div class="tabs-title" id="baseInfo">
                                    基本信息
                                </div>
                                <div style="width: 100%" class="form">
                                    <el-form
                                        :model="basicFormData"
                                        label-width="150px"
                                    >
                                        <BillTop
                                            title="供应商库变更详情"
                                            @cancel="handleClose"
                                        ></BillTop>
                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="统一社会信用代码"
                                                >
                                                    {{
                                                        basicFormData.creditCode
                                                    }}
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="供应商名称"
                                                >
                                                    {{
                                                        basicFormData.supplierName
                                                    }}
                                                    <img
                                                        v-if="
                                                            isLoad &&
                                                            oldEditData.supplierName !=
                                                                basicFormData.supplierName
                                                        "
                                                        class="img-style"
                                                        src="@/assets/biangeng.png"
                                                        alt=""
                                                    />
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item label="类型">
                                                    {{
                                                        basicFormData.supplierTypeKey
                                                    }}
                                                    <img
                                                        v-if="
                                                            isLoad &&
                                                            oldEditData.supplierTypeKey !=
                                                                basicFormData.supplierTypeKey
                                                        "
                                                        class="img-style"
                                                        src="@/assets/biangeng.png"
                                                        alt=""
                                                    />
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item label="法人代表">
                                                    {{ basicFormData.deputy }}
                                                    <img
                                                        v-if="
                                                            isLoad &&
                                                            oldEditData.deputy !=
                                                                basicFormData.deputy
                                                        "
                                                        class="img-style"
                                                        src="@/assets/biangeng.png"
                                                        alt=""
                                                    />
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                        <el-row>
                                            <el-form-item label="注册地址">
                                                {{
                                                    showAddress(
                                                        basicFormData.registerAddInfo
                                                    )
                                                }}
                                                <img
                                                    v-if="
                                                        isLoad &&
                                                        oldEditData.registerAddInfo !=
                                                            basicFormData.registerAddInfo
                                                    "
                                                    class="img-style"
                                                    src="@/assets/biangeng.png"
                                                    alt=""
                                                />
                                            </el-form-item>
                                        </el-row>
                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item label="联系电话">
                                                    {{
                                                        basicFormData.contactTel
                                                    }}
                                                    <img
                                                        v-if="
                                                            isLoad &&
                                                            oldEditData.contactTel !=
                                                                basicFormData.contactTel
                                                        "
                                                        class="img-style"
                                                        src="@/assets/biangeng.png"
                                                        alt=""
                                                    />
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="注册资本（万元）"
                                                >
                                                    {{
                                                        basicFormData.registerCapital
                                                    }}
                                                    <img
                                                        v-if="
                                                            isLoad &&
                                                            oldEditData.registerCapital !=
                                                                basicFormData.registerCapital
                                                        "
                                                        class="img-style"
                                                        src="@/assets/biangeng.png"
                                                        alt=""
                                                    />
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item label="传真">
                                                    {{ basicFormData.fax }}
                                                    <img
                                                        v-if="
                                                            isLoad &&
                                                            oldEditData.fax !=
                                                                basicFormData.fax
                                                        "
                                                        class="img-style"
                                                        src="@/assets/biangeng.png"
                                                        alt=""
                                                    />
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item label="邮箱">
                                                    {{ basicFormData.email }}
                                                    <img
                                                        v-if="
                                                            isLoad &&
                                                            oldEditData.email !=
                                                                basicFormData.email
                                                        "
                                                        class="img-style"
                                                        src="@/assets/biangeng.png"
                                                        alt=""
                                                    />
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item label="纳税类别">
                                                    {{
                                                        basicFormData.taxTypeName
                                                    }}
                                                    <img
                                                        v-if="
                                                            isLoad &&
                                                            oldEditData.taxTypeName !=
                                                                basicFormData.taxTypeName
                                                        "
                                                        class="img-style"
                                                        src="@/assets/biangeng.png"
                                                        alt=""
                                                    />
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item label="邮编">
                                                    {{ basicFormData.postCode }}
                                                    <img
                                                        v-if="
                                                            isLoad &&
                                                            oldEditData.postCode !=
                                                                basicFormData.postCode
                                                        "
                                                        class="img-style"
                                                        src="@/assets/biangeng.png"
                                                        alt=""
                                                    />
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="增值税一般纳税人资格查询"
                                                    ><a
                                                        href="https://etax.sichuan.chinatax.gov.cn/"
                                                        target="_blank"
                                                        >查询</a
                                                    >
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="四川住房城乡建设厅信息查询"
                                                >
                                                    <a
                                                        href="http://202.61.88.188/xxgx/index.aspx"
                                                        target="_blank"
                                                        >查询</a
                                                    ></el-form-item
                                                >
                                            </el-col>
                                        </el-row>
                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="信用信息查询"
                                                >
                                                    <a
                                                        href="http://www.gsxt.gov.cn/index.html"
                                                        target="_blank"
                                                        >查询</a
                                                    >
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12"> </el-col>
                                        </el-row>
                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item
                                                    label="是否为境外单位"
                                                >
                                                    <span
                                                        v-if="
                                                            basicFormData.isAbroadUnit ==
                                                            1
                                                        "
                                                    >
                                                        {{ '是' }}
                                                    </span>
                                                    <span
                                                        v-if="
                                                            basicFormData.isAbroadUnit ==
                                                            0
                                                        "
                                                    >
                                                        {{ '否' }}
                                                    </span>
                                                    <img
                                                        v-if="
                                                            isLoad &&
                                                            oldEditData.isAbroadUnit !=
                                                                basicFormData.isAbroadUnit
                                                        "
                                                        class="img-style"
                                                        src="@/assets/biangeng.png"
                                                        alt=""
                                                    />
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item label="管理单位">
                                                    {{
                                                        basicFormData.manageOrgName
                                                    }}
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                        <el-row>
                                            <el-col :span="12">
                                                <el-form-item label="信用等级">
                                                    <span>
                                                        {{
                                                            basicFormData.creditLevel ==
                                                            '0'
                                                                ? '待定'
                                                                : basicFormData.creditLevel ==
                                                                  '1'
                                                                ? 'A'
                                                                : basicFormData.creditLevel ==
                                                                  '2'
                                                                ? 'B'
                                                                : basicFormData.creditLevel ==
                                                                  '3'
                                                                ? 'C'
                                                                : basicFormData.creditLevel ==
                                                                  '4'
                                                                ? 'D'
                                                                : basicFormData.creditLevel ==
                                                                  '5'
                                                                ? 'S'
                                                                : ''
                                                        }}</span
                                                    >
                                                </el-form-item>
                                            </el-col>
                                            <el-col :span="12">
                                                <el-form-item label="状态">
                                                    {{
                                                        statusLable(
                                                            basicFormData.state
                                                        )
                                                    }}
                                                </el-form-item>
                                            </el-col>
                                        </el-row>
                                    </el-form>
                                </div>
                            </div>
                        </div>

                        <!-- ------------------------------------------------------------------------------------- -->
                    </div>

                    <!-- 资质信息 -->
                    <div id="aptitudeCon" class="con">
                        <div class="tabs-title" id="aptitude">资质信息</div>
                        <div class="e-table">
                            <div class="top"></div>
                            <el-table
                                :data="aptitudeTable"
                                border
                                style="width: 100%"
                                ref="table"
                                class="table"
                                :max-height="$store.state.tableHeight"
                                @cell-mouse-enter="cellMouseEnter"
                                @cell-mouse-leave="cellMouseLeave"
                                :cell-class-name="cellClsNm"
                                :row-class-name="tableRowClass"
                                :header-cell-style="{ textAlign: 'center' }"
                                :cell-style="{ textAlign: 'center' }"
                                v-sortTable="{
                                    tableData: aptitudeTable,
                                    _this: this,
                                    ref: 'table'
                                }"
                            >
                                <el-table-column type="selection" width="55">
                                </el-table-column>
                                <el-table-column
                                    type="index"
                                    width="55"
                                    label="序号"
                                ></el-table-column>
                                <el-table-column
                                    prop="certNo"
                                    label="证书编号"
                                    width="150"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="certTypeValue"
                                    label="证书类型"
                                    width="100"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="qualificationLevelId"
                                    label="主营范围/证书等级"
                                    width="200"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="startDate"
                                    label="有效期开始日期"
                                    width="150"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="endDate"
                                    label="有效期结束日期"
                                    width="150"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="fileName"
                                    label="文件名"
                                    width="100"
                                >
                                    <template slot-scope="scope">
                                        <span
                                            @click="preview(scope.row)"
                                            style="color: blue; cursor: pointer"
                                        >
                                            {{ scope.row.fileName }}
                                        </span>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="size"
                                    label="大小"
                                    width="100"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="gmtCreate"
                                    label="上传时间"
                                    width="100"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="founderName"
                                    label="上传人"
                                    width="100"
                                >
                                </el-table-column>
                            </el-table>
                        </div>
                    </div>

                    <!-- 历史业绩 -->
                    <div id="firmPerformanceCon" class="con">
                        <div class="tabs-title" id="firmPerformance">
                            历史业绩
                        </div>
                        <div class="e-table">
                            <el-table
                                :data="performanceTable"
                                border
                                style="width: 100%"
                                ref="table"
                                class="table"
                                :max-height="$store.state.tableHeight"
                                @cell-mouse-enter="cellMouseEnter"
                                @cell-mouse-leave="cellMouseLeave"
                                :cell-class-name="cellClsNm"
                                :row-class-name="tableRowClass"
                                :header-cell-style="{ textAlign: 'center' }"
                                :cell-style="{ textAlign: 'center' }"
                                v-sortTable="{
                                    tableData: performanceTable,
                                    _this: this,
                                    ref: 'table'
                                }"
                            >
                                <el-table-column type="selection" width="55">
                                </el-table-column>
                                <el-table-column
                                    type="index"
                                    width="55"
                                    label="序号"
                                ></el-table-column>
                                <el-table-column
                                    prop="contractName"
                                    label="合同名称"
                                    width="150"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="projectName"
                                    label="项目名称"
                                    width="150"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="contractAmount"
                                    label="合同金额"
                                    width="150"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="startDate"
                                    label="开工时间"
                                    width="150"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="endDate"
                                    label="竣工时间"
                                    width="150"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="signingTime"
                                    label="签订日期"
                                    width="150"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="cumulativeAmount"
                                    label="累计结算金额"
                                    width="150"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="projectLeader"
                                    label="项目负责人"
                                    width="150"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="witnessName"
                                    label="机材负责人"
                                    width="150"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="witnessTel"
                                    label="机材负责人电话"
                                    width="150"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="proxy"
                                    label="委托代理"
                                    width="150"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="proxyPhone"
                                    label="委托代理联系电话"
                                    width="150"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="opinion"
                                    label="最新动态评价意见"
                                    width="150"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="fileName"
                                    label="业绩附件"
                                    width="150"
                                >
                                    <template slot-scope="scope">
                                        <span
                                            @click="preview1(scope.row)"
                                            style="color: blue; cursor: pointer"
                                        >
                                            {{ scope.row.fileName }}
                                        </span>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="contractStateDesc"
                                    label="合同状态"
                                    width="150"
                                >
                                    <template slot-scope="{ row }">
                                        {{
                                            row.source == '1'
                                                ? '- -'
                                                : options.stateArr[
                                                      row.contractState
                                                  ]
                                        }}
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="source"
                                    label="业绩来源"
                                    width="150"
                                >
                                    <template slot-scope="scope">
                                        {{
                                            scope.row.source == 0
                                                ? '系统内'
                                                : '系统外'
                                        }}
                                    </template>
                                </el-table-column>
                            </el-table>
                        </div>
                    </div>
                    <!-- 解除处罚记录 -->
                    <div id="alterationCon" class="con">
                        <div class="tabs-title" id="alteration">
                            解除处罚记录
                        </div>
                        <div class="e-table">
                            <el-table
                                :data="tableData"
                                border
                                style="width: 100%"
                                ref="table"
                                class="table"
                                :max-height="$store.state.tableHeight"
                                @cell-mouse-enter="cellMouseEnter"
                                @cell-mouse-leave="cellMouseLeave"
                                :cell-class-name="cellClsNm"
                                :row-class-name="tableRowClass"
                                :header-cell-style="{ textAlign: 'center' }"
                                :cell-style="{ textAlign: 'center' }"
                                v-sortTable="{
                                    tableData: tableData,
                                    _this: this,
                                    ref: 'table'
                                }"
                            >
                                <el-table-column
                                    prop="a1"
                                    label="解除处罚原因"
                                    min-width="200"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="a"
                                    label="经办人"
                                    width="200"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="b"
                                    label="提交时间"
                                    width="200"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="c"
                                    label="状态"
                                    width="200"
                                >
                                </el-table-column>
                            </el-table>
                        </div>
                    </div>
                    <!-- 审核历史 -->
                    <div id="accessoryCon" class="con">
                        <div class="tabs-title" id="accessory">审核历史</div>
                        <div class="e-table">
                            <el-table
                                :data="tableData"
                                border
                                ref="table"
                                class="table"
                                style="width: 100%"
                                :max-height="$store.state.tableHeight"
                                @cell-mouse-enter="cellMouseEnter"
                                @cell-mouse-leave="cellMouseLeave"
                                :cell-class-name="cellClsNm"
                                :header-cell-style="{ textAlign: 'center' }"
                                :cell-style="{ textAlign: 'center' }"
                                v-sortTable="{
                                    tableData: tableData,
                                    _this: this,
                                    ref: 'table'
                                }"
                            >
                                <el-table-column
                                    prop="a1"
                                    label="审核级次"
                                    width="200"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="a"
                                    label="审核人"
                                    width="200"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="b"
                                    label="审核人岗位"
                                    width="200"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="c"
                                    label="通知时间"
                                    width="200"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="c"
                                    label="审核时间"
                                    width="200"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="c"
                                    label="审核意见"
                                    min-width="200"
                                >
                                </el-table-column>
                            </el-table>
                        </div>
                    </div>
                </div>
            </el-tabs>
        </div>
        <div id="seat" :style="{ height: seatHeight + 'px' }"></div>
        <div class="buttons">
            <ComExaButtons
                :auditState="auditState"
                :state="basicFormData.state"
                :founderId="founderId"
                @exas="exas"
            />
            <el-button size="small" @click="handleClose">取消</el-button>
        </div>
    </div>
</template>

<script>
import examine from '@/api/OutsourcingartyAdmin/subcontractorAdmin/examine.js'
// 变更接口
import supplierChange from '@/api/OutsourcingartyAdmin/supplier/supplierChange'
// 按钮
import ComExaButtons from '@/components/common/exaButtons'
// 评价历史
import { getEvaluateList } from '@/api/OutsourcingartyAdmin/subcontractorAdmin/subcontractor.js'
import { toVoid } from '@/api/OutsourcingartyAdmin/subcontractorAdmin/subcontractor.js'
import {
    showSuccessPop,
    openAppClient,
    throttle,
    showLoading,
    hideLoading
} from '@/utils/common'
// 编辑接口
import Supplier from '@/api/OutsourcingartyAdmin/supplier/supplier'
import '@/utils/jquery.scrollTo.min'

export default {
    components: {
        ComExaButtons
    },
    data () {
        return {
            tabsName: 'baseInfo',
            userName: '',
            founderId: '', //登录人id
            form: {
                name: '',
                region: '',
                date1: '',
                date2: '',
                delivery: false,
                type: [],
                resource: '',
                desc: ''
            },
            tableData: [],
            value: '',
            textarea: '',

            screenWidth: 0,
            screenHeight: 0,
            lastConHeight: 0,
            clickTabFlag: false, // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            //基本信息表单数据
            basicFormData: {
                creditCode: '', //统一社会信用代码
                supplierName: '', //分包商名称
                supplierTypeKey: '', //类型
                deputy: '', //法人代表
                registerAddProvince: '', //注册地址省
                registerAddCity: '', //注册地址市
                registerAddDistrict: '', //注册地址先去
                registerAddInfo: '', //注册地址详细
                contactTel: '', //联系电话
                registerCapital: '', //注册资本
                fax: '', //传真
                email: '', //邮箱
                taxTypeName: '', //纳税类别
                postCode: '', //邮编
                manageOrgName: '', //管理单位
                isAbroadUnit: '', //是否为境外单位
                creditLevelName: '2', //信用等级
                state: 0 //状态
            },
            aptitudeTable: [], //资质信息
            performanceTable: [], //历史业绩
            changeHistoryData: [], //变更历史
            evaluateTable: [], //评价历史
            auditState: {}, //按钮状态
            winEvent: {}, //保存事件，跳转页面的时候，结束事件，优化性能
            billid: '', //单据id
            oldEditData: {}, //原单
            isLoad: false, //判断接口值回来没有
            // 作废参数
            nullifyParams: {
                billId: this.billid, //单据id
                billType: '604101', //单据类型
                nullifyCreated: '',
                nullifyCreator: '',
                nullifyCreatorId: '',
                nullifyDescription: '',
                nullifyReason: ''
            }
        }
    },
    computed: {
        // 判断状态
        statusLable () {
            return param => {
                const state = this.$store.state.equip.equipData.state
                const obj = state.find(x => x.value == param)
                if (obj !== undefined) {
                    return obj.label
                }
            }
        },
        // 填补底部空白，以使高度够滚动
        seatHeight () {
            return this.screenHeight - 108 - this.lastConHeight
        },
        showAddress () {
            return value => {
                if (!value) return ''
                try {
                    let obj = JSON.parse(value)
                    const address = obj.address ? obj.address.join('-') : ''
                    const detail = obj.detail
                    let str = ''
                    if (address && detail) {
                        str = address + '-' + detail
                    } else if (!address && detail) {
                        str = detail
                    } else if (address && !detail) {
                        str = address
                    }
                    return str
                } catch (err) {
                    return value
                }
            }
        }
    },
    created () {
        this.billid = this.$route.query.billid
        this.founderId = localStorage.getItem('userId')
        this.getBasicData() //进入页面就获取基本信息数据
        this.qualificationList(this.billid) //初始化资质信息列表
        this.performanceList(this.billid) //初始化历史业绩
        this.getChangeList(this.billid) //变更历史
        this.getList() //评价历史
        this.getCurrentUnitInfo()
    },
    mounted () {
        // 获取最后一个内容区域的高度，计算底部空白
        this.getLastConHeight()

        // 保存所有tabName
        const arr = [
            'baseInfo',
            'aptitude',
            'firmPerformance',
            'accessory',
            'auditHistory',
            'alteration',
            'evaluate'
        ]
        let $idsTop = []
        const onScroll = () => {
            // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            if (this.clickTabFlag) {
                return
            }
            if (!$idsTop[$idsTop.length - 1]) {
                $idsTop = arr.map(item => {
                    const $item = document.getElementById(item)
                    let itemTop = null
                    if ($item) {
                        itemTop = $item.offsetTop
                    }
                    return itemTop
                })
            }
            const scrollTop =
                document.documentElement.scrollTop || document.body.scrollTop
            // 倒序查找
            let curLocal = 0
            for (let len = $idsTop.length, i = len - 1; i >= 0; i--) {
                let item = $idsTop[i]
                if (scrollTop + 1 >= item) {
                    curLocal = i
                    break
                }
            }
            // 设置对应tabName
            this.tabsName = arr[curLocal]
        }
        this.winEvent.onScroll = onScroll
        window.addEventListener('scroll', this.winEvent.onScroll)
        this.screenWidth =
            document.documentElement.clientWidth - this.topHeight
        this.screenHeight =
            document.documentElement.clientHeight - this.topHeight
        const onResize = () => {
            this.screenWidth = document.documentElement.clientWidth
            this.screenHeight = document.documentElement.clientHeight
            $idsTop = arr.map(item => {
                const itemTop = document.getElementById(item).offsetTop
                return itemTop
            })
        }
        this.winEvent.onResize = throttle(onResize, 500)
        window.addEventListener('resize', this.winEvent.onResize)
    },
    beforeDestroy () {
        window.removeEventListener('scroll', this.winEvent.onScroll)
        window.removeEventListener('resize', this.winEvent.onResize)
    },
    methods: {
        //修改行样式
        tableRowClass ({ row }) {
            if (row.state == -1) {
                return 'red'
            } else if (row.state == 1) {
                return 'green'
            } else if (row.state == 2) {
                return 'yellow'
            }
            return ''
        },
        //获取基本信息数据
        async getBasicData () {
            let res = await supplierChange.supplierChangeBase(this.billid)
            this.isLoad = true
            res.supplierTypeKey = res.supplierTypeKey.join(',')
            let data = JSON.parse(res.registerAddInfo)
            res.registerAddInfo = data.address.join('') + data.detail
            this.basicFormData = res
            this.getyuandan(res.sourceId)
        },
        async getyuandan (val) {
            let res = await Supplier.factualOutsourcerBase({ id: val })
            this.oldEditData = JSON.parse(JSON.stringify(res))
            let data = JSON.parse(this.oldEditData.registerAddInfo)
            this.oldEditData.registerAddInfo =
                data.address.join('') + data.detail
            this.oldEditData.isAbroadUnit = res.isAbroadUnit + ''
        },
        // 获取最后一个内容区域的高度，计算底部空白
        getLastConHeight () {
            let si = setInterval(() => {
                // 因为dom异步加载，通过轮询找到渲染后的dom，获取高度
                if (document.getElementById('accessoryCon')) {
                    const lastConHeight =
                        document.getElementById('accessoryCon').offsetHeight
                    console.log('lastConHeight: ', lastConHeight)
                    this.lastConHeight = lastConHeight
                    console.log('this.lastConHeight', this.lastConHeight)
                    clearInterval(si)
                    si = null
                }
            }, 100)
        },
        //删除
        delData () {
            this.$Ajax
                .httpGet({
                    url: '/outer/supplier/delete',
                    params: {
                        id: this.billid
                    },
                    headers: {
                        'Content-Type': 'application/x-www-form-urlencoded'
                    }
                })
                .then(res => {
                    this.$message({
                        showClose: true,
                        type: 'success',
                        message: res.message
                    })
                    this.$router.push('./supplierbePutinstorage')
                })
        },

        submit () {},
        handleFullScreen () {
            this.fullscreen = !this.fullscreen
        },
        //取消
        handleClose () {
            this.dialogVisible = false
            this.$router.push('./supplierbePutinstorage')
        },
        cellClsNm ({ column }) {
            if (column.label === '') {
                return 'fixed-left'
            }
        },
        cellMouseEnter (row) {
            this.MouseEnterId = row.id
        },
        cellMouseLeave () {
            this.MouseEnterId = 0
        },
        onChangeTab (e) {
            console.log('clickTabFlag: ', this.clickTabFlag)
            $.scrollTo(`#${e.name}`, 500)
            // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            this.clickTabFlag = true
            // 动画结束后，恢复状态
            setTimeout(() => {
                this.clickTabFlag = false
            }, 600)
        },
        // 资质信息
        async qualificationList (val) {
            // 如果有isTableRowClass，则调编辑页面的资质接口，否则调变更页面的资质接口
            let data = await supplierChange.supplierQualificationsChangeList(
                val
            )
            console.log(111111, data)
            // 如果时间是99999，则改为永久
            data.map(item => {
                if (new Date(item.endDate).getFullYear() == 9999) {
                    item.endDate = '永久'
                }
            })
            this.aptitudeTable = data
        },
        // 历史业绩
        async performanceList (val) {
            let data = await await supplierChange.supplierPerformanceChangeList(
                { billId: val, keyword: '' }
            )
            this.performanceTable = data
        },
        // 变更历史列表查询
        async getChangeList (val) {
            let data = await supplierChange.supplierChangeList(val)
            this.changeHistoryData = data
        },
        // 评价历史查询
        async getList () {
            let data = await getEvaluateList({ id: this.billid })
            this.evaluateTable = data
        },
        //变更按钮
        chengeBtn () {
            let billid = this.basicFormData.id
            this.$router.push({
                path: '/supplierbePutinstorageChangeAdd',
                query: { billid }
            })
        },
        //预览附件
        preview (val) {
            this.aptitudeTable.some(item => {
                if (item.id == val.id) {
                    window.open(item.dialogImage)
                }
            })
        },
        //业绩附件
        preview1 (val) {
            this.performanceTable.some(item => {
                if (item.id == val.id) {
                    window.open(item.dialogImage)
                }
            })
        },
        // 获取按钮状态
        getCurrentUnitInfo () {
            examine
                .getCurrentUnitInfo({
                    billId: this.$route.query.billid,
                    billType: 604101,
                    freeNextUnitIndex: 0,
                    freeNextUser: '',
                    isPass: true,
                    isShareInAudit: true,
                    opinion: ''
                })
                .then(res => {
                    console.log(444444, res)
                    this.auditState = res
                })
        },
        // 审核
        audit () {
            // 客户端弹窗弹出本地页面
            openAppClient('/exaDialog', '填写审核意见', () => {
                // 审核拿到审核弹窗的意见
                const auditParams = JSON.parse(localStorage.vuex).auditParams
                // 将审核意见赋值给参数传给后端
                examine
                    .audit({
                        billId: this.$route.query.billid,
                        billType: 604101,
                        freeNextUnitIndex: 0,
                        freeNextUser: '',
                        isPass: auditParams.isPass,
                        isShareInAudit: true,
                        opinion: auditParams.opinion
                    })
                    .then(() => {
                        this.clientPop('suc', '审核成功')
                        // 保存成功置空数据
                        this.firmPerformanceTable = []
                        this.aptitudeTable = []
                        // 返回列表
                        this.handleClose()
                    })
            }, null, null, null, 'small')
        },
        // 撤回
        withdrawChange () {
            this.clientPop('info', '是否确认撤回', this.callbackWithdraw)
        },
        // 撤回确认回调
        async callbackWithdraw () {
            console.log(1111, this.billid)
            let { code } = await examine.undoAudit({
                billId: this.billid, //单据id
                billType: '604101', //单据类型
                freeNextUnitIndex: 0,
                freeNextUser: '',
                isPass: true,
                isShareInAudit: true,
                opinion: ''
            })
            if (code == 200) {
                showSuccessPop('撤回成功')
                // 返回列表
                this.handleClose()
            } else {
                showSuccessPop('撤回失败')
            }
        },
        // 作废
        toVoidChange () {
            this.clientPop('info', '是否确认作废', this.callback)
        },
        // 作废确认回调
        async callback () {
            // 客户端弹窗弹出本地页面
            const auditParams = JSON.parse(localStorage.vuex).auditParams
            openAppClient('/nullifyDialog', '单据作废原因', async () => {
                showLoading()
                await toVoid({
                    billId: this.billid, //单据id
                    billType: '604101', //单据类型
                    nullifyCreated: '',
                    nullifyCreator: '',
                    nullifyCreatorId: '',
                    nullifyDescription: auditParams.nullifyDescription,
                    nullifyReason: auditParams.nullifyReason
                }).catch(() => {
                    this.clientPop('suc', '作废失败')
                })
                hideLoading()
            })
        },
        // 删除方法
        ctDelete () {
            this.clientPop(
                'info',
                '确定要删除吗？数据删除后不可恢复，请谨慎操作',
                this.delent
            )
        },
        //删除回调
        delent () {
            this.$Ajax
                .httpGet({
                    url: '/outer/supplier/delete',
                    params: {
                        id: this.billid
                    },
                    headers: {
                        'Content-Type': 'application/x-www-form-urlencoded'
                    }
                })
                .then(res => {
                    if (res.code == 200) {
                        showSuccessPop('删除成功！')
                        this.isSkip = true
                    }
                    this.$router.replace('/supplierbePutinstorage')
                })
        },
        // 按钮组件触发事件
        exas (data) {
            switch (data) {
            case 'audit':
                this.audit() //审核
                break
            case 'undoAudit':
                this.withdrawChange() //撤回
                break
            case 'submitCommit':
                this.submit() //提交
                break
            case 'submit':
                this.save() //保存
                break
            case 'nullify':
                this.toVoidChange() //作废
                break
            case 'deleteData':
                this.ctDelete() //删除
                break
            default:
                break
            }
        }
    }
}
</script>

<style lang="scss" scoped>
.buttons {
    left: 0;
}
.e-form {
    margin-bottom: 80px;
    padding: 0 20px;
    .tabs-title::before {
        content: '';
        height: 22px;
        width: 8px;
        border-radius: 40px;
        background-color: #2e61d7;
        display: block;
        position: absolute;
        left: 20px;
        margin-right: 20px;
    }
}

.e-table {
    background: #fff;
}
.img-style {
    width: 25px;
    height: 25px;
    margin: 0px 0px 4px 5px;
}
::v-deep .el-table__body-wrapper::-webkit-scrollbar {
    width: 6px; // 横向滚动条
    height: 10px; // 纵向滚动条
}
// 滚动条的滑块
::v-deep .el-table__body-wrapper::-webkit-scrollbar-thumb {
    background-color: #ddd;
    border-radius: 5px;
}

.el-tab-pane {
    margin-left: -10px;
}
::v-deep.el-upload-dragger {
    height: 90px;
    margin-left: 300px;
}
</style>
